# Classification Tree with rpart
library(rpart)

trainVector <-read.csv(file='data/spambase.data.txt', head=FALSE, sep = ",", dec=".")
x <- data.frame(trainVector)
xtabs( ~ V58, data = trainVector)
# grow tree 
fit <- tree(formula = V58 ~. ,method="class", data=trainVector)

#printcp(fit) # display the results 
#plotcp(fit) # visualize cross-validation results 
summary(fit) # detailed summary of splits

# plot tree 
plot(fit)#	, uniform=TRUE, 
#		main="Classification Tree for Spam")
text(fit)#, use.n=TRUE, all=TRUE, cex=.8)

# create attractive postscript plot of tree 
#post(fit, file = "tree.ps", 
#		title = "Classification Tree for Spam")